package nil.ed.simulator.request.biz.qq.activity;

import lombok.extern.slf4j.Slf4j;
import nil.ed.simulator.request.client.activity.AbstractHttpActivity;
import nil.ed.simulator.request.enums.ActivityGroup;
import nil.ed.template.FreeMarkerTemplateEngineAdapter;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;

import java.util.Map;

/**
 * App Index 活动.
 * @author lidelin.
 */
@Slf4j
public class Seq003XLoginActivity extends AbstractHttpActivity {

    private static final String X_LOGIN_URL = "https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=${appid}&style=32&hide_border=0&hide_close_icon=1&hide_feedback=1&hide_reg=1&target=top&target=top&hide_title_bar=1&s_url=https://aq.qq.com/cn2/manage/mbtoken/app_index&lang=0&qlogin_jumpname=aqjump&qlogin_param=aqdest=https%3A//aq.qq.com/cn2/manage/mbtoken/app_index";

    @Override
    protected HttpUriRequest getRequest(Map<String, Object> attrMap) {
        String url = FreeMarkerTemplateEngineAdapter.INSTANCE.process(X_LOGIN_URL, attrMap);
        log.info("qq　= {} xlogin url = {}", attrMap.get("qq"), url);
        return new HttpGet(url);
    }

    @Override
    protected boolean doFinalProcess(HttpResponse response, Map<String, Object> customAttrMap) {
        return true;
    }

    @Override
    public ActivityGroup getGroup() {
        return ActivityGroup.QQ_LOGIN;
    }

    @Override
    public int getSort() {
        return 10;
    }
}
